<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>SpringBoot-Thymeleaf案例2</title>
</head>
<body>
<!--Thymeleaf标准变量表达式获取数据-->
    <td th:text="${user.nick}">x</td>
    <td th:text="${user.phone}"> 1370xxxxxx </td>
    <td th:text="${user.email}"> xxxx.com</td>
    <td th:text="${user.address}">北京xx </td>
    <span th:text="${hello}">你好</span>
<!--Thymeleaf选择变量表达式获取数据-->
    <p th:object="${user}">
        <span th:text="*{nick}" ></span>
        <span th:text="*{phone}"></span>
        <span th:text="*{email}"></span>
        <span th:text="*{address}"></span>
    </p>
<!--Thymeleaf混合变量表达式获取数据-->
    <p th:object="${user}">
        <span th:text="${user.nick}" ></span>
        <span th:text="*{phone}"></span>
        <span th:text="${user.email}"></span>
        <span th:text="*{address}"></span>
    </p>
<!--Thymeleaf选择变量表达式获取数据之变种* 全域查找-->
    <div>
        <span> nick: <span th:text= "*{user.nick}" >张</span> </span>
        <span> phone: <span th:text= "*{user.phone}" >三</span> </span>
        <span> email: <span th:text= "*{user.email}" >北京</span> </span>
        <span> address: <span th:text= "*{user.address}" >北京</span> </span>
    </div>

<a href= "info.html" th:href= "@{'http://localhost:8080/getUser?id='+ ${user.id}}" >查看</a>
<a href= "info.html" th:href= "@{'getUser?id='+${user.id}}">查看</a>
<a href= "info.html" th:href= "@{'/getUser?id='+${user.id}}">查看</a>

<p th:each="user : ${userList}">
    <span th:text="${userStat.count}">x</span>
    <span th:text="${user.id}">x</span>        <span th:text="${user.nick}">xx</span>
    <span th:text="${user.phone}">xxx</span>   <span th:text="${user.email}">xxxx</span>
</p>

Map：
<p th:each="userMapVal : ${userMap}">
    <span th:text="${userMapVal.key}">x</span>
    <span th:text="${userMapVal.value.id}">x</span>       <span th:text="${userMapVal.value.nick}">xx</span>
    <span th:text="${userMapVal.value.phone}">xxx</span>  <span th:text="${userMapVal.value.email}">xxxx</span>
</p>

数组：
<p th:each="userArray : ${users}">
    <span th:text="${userArray.id}">x</span>       <span th:text="${userArray.nick}">xx</span>
    <span th:text="${userArray.phone}">xxx</span>  <span th:text="${userArray.email}">xxxx</span>
</p>
<!-- th:id属性 -->
<span id="username">aaa</span>
<span th:id="${username}">bbb</span>
<!-- th:if属性 -->
<span th:if="${sex == '1'}">男</span>
<span th:if="${sex == '2'}">女</span>
<!-- th:unless属性 -->
<span th:unless="${sex == '1'}">男</span>
<span th:unless="${sex == '2'}">女</span>

<div th:switch= "${sex}">
    <p th:case="1">性别:男</p>
    <p th:case="2">性别:女</p>
    <p th:case="t">性别:未知</p>
</div>

<script th:src= "@{/js/jiquery-2.4.min.js}"> </script>
<img th:src= "@{/image/log.png}"/>
<div>
     <input type="text" id= "email" name= "email" th:text= "${user.email}" />
</div>
<div>
    <input type= "text" id= "phone" name= "phone" th:value= "${user.phone}" />
</div>

<input type= "text" id= "address" name= "address" th:attr= "value= ${user.address}" >

<span th:attr="data-ref= ${user.phone}" th:onclick="clickMe()">22</span>
<script>
    function clickMe() {
        alert("click");
    }
</script>
<!--内联脚本-->
<script th:inline= "javascript" type= "text/javascript" >
    var user = [[${user.phone}]];
    alert(user);
</script>
<script th:inline= "javascript" type= "text/javascript" >
    var mge = "hello," + [[${user.phone}]];
    alert(mge);
</script>

<div th:sty1e="'display:none;'">helloSpringboot</div>

<form id= "login" th:action= "@{/login}" th:method= "post" > ... </form>

<div th:inline= "text">
<span>[[${user.nick}]]</span>
</div>
<!--字面量-->
<a th:href="@{'api/getUser?id=' + ${user.id}}">修改</a>
<p>今年是<span th:text= "2017"> 1949</span>年</p>
<p>20年后，将是<span th:text="2017 + 20">1969</span>年</p>
<!--判断true和false-->
<p th:if="${isFlag == true}">
    执行操作
</p>
<p th:if="${users == null}">userlist为空</p>
<p th:if="${users != null}">userlist不为空</p>
<!--字符串拼接-->
<span th:text= "'当前是第'+${sex}+'页,共'+ ${sex}+'页'"> </span>
<span th:text="|当前是第${sex}页,共${sex}页|"> </span>
<!--三元运算符-->
<div>
    <span th:text= "${sex eq '1'} ? '男' : '女' ">末知</span>
</div>
<!--表达式基本对象-->
<span th:text="${#request.getAttribute('name')}">name</span>
<div>
    <span th:text="${#session.getAttribute('address')}">name</span>
    <span th:inline="text">
        [[${#session.id}]]
        [[${#session.lastAccessedTime}]]
    </span>
</div>
<span th:text= "${#dates.format(curDate,'yyy-MM-dd HH:mm:ss')}"> </span>


</body>
</html>